Skip to content

Fix continued fraction precision for large integers - #1

Open
Chickerson64 wants to merge 1 commit into
masterfrom
codex/lab6-15655
Open

Chickerson64 wants to merge 1 commit into
masterfrom
codex/lab6-15655

Conversation

@Chickerson64

Copy link
Copy Markdown
Owner

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

This change fixes the precision and overflow issue described in TheAlgorithms#15655.

The continued_fraction implementation previously used floating-point division, which could produce incorrect continued-fraction terms or raise OverflowError for large integers.

The fix replaces floating-point division with exact integer floor division and removes the unused floor import.

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is my own work, with AI assistance disclosed below.
  • I understand that automated tests must pass.
  • This PR changes only one algorithm file.
  • Existing naming conventions and type hints are preserved.
  • Existing doctests were preserved and passed.
  • New algorithm references — not applicable to this bug fix.

Verification

  • Existing doctests passed.
  • Regression checks passed for ordinary, negative, and extremely large fractions.
  • Ruff lint and formatting checks passed.
  • Full pre-commit validation was limited by unavailable Python 3.15t.

AI assistance and scope

Codex assisted with implementation and independent code review. The change was tested locally.

This is an independent educational contribution for CS440 Lab 6. Similar fixes already have open upstream PRs.

This PR is intended exclusively for my personal fork, Chickerson64/Python, and is not being submitted to TheAlgorithms upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant